import pygame
import Common

class Map():

   boundaries = 1600, 1200

   def __init__(self, x, y, ents):

      self.camera = [x, y]
      
      if type(ents) == 'list':
         self.ents = ents

      self.scrents = []
      self.scr = pygame.Surface((800, 600), flags=0)
      self.tex, self.texrect = Common.load_bitmap("ground.png", 0)

   def tile(self):

      
      iy = 0
      while (iy) < 600:
         ix = 0
         while (ix) < 800:

            self.scr.blit(self.tex, (ix, iy))
            ix += 64

         iy += 64

      img = self.scr.convert()

      return img


   def setents(self, x, y, ents):

      self.camera = [x, y]

      if type(ents) == 'list':
         self.ents = ents

      boundx = [self.camera[0] - 400, self.camera[0] + 400]
      boundy = [self.camera[1] - 300, self.camera[1] + 300]

      i = 1
      for i in len(self.ents):
         if self.ents[i].x >= boundx[0] and self.ents[i].x <= boundx[1]:
            if self.ents[i].y >= boundy[0] and self.ents[i].y <= boundy[1]:
               self.scrents[i] = self.ents[i]
               